package cn.newgrand.common;

import java.io.File;
import java.io.IOException;

import javax.swing.JOptionPane;

import org.jivesoftware.Spark;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.util.log.Log;

public class NativeTools {
	public static void openFile(File downloadedFile) {
        try {
            if (!Spark.isMac()) {
                boolean opened = SparkManager.getNativeManager().openFile(downloadedFile);
                if (!opened) {
                    JOptionPane.showMessageDialog(SparkManager.getMainWindow(),"can not open");
                }
            }
            else if (Spark.isMac()) {
                Runtime.getRuntime().exec("open " + downloadedFile.getCanonicalPath());
            }
        }
        catch (IOException e1) {
            Log.error(e1);
        }
    }
	public static void main(String[] args){
		System.out.println(Spark.getSparkUserHome());
		System.out.println(Spark.getUserHome());
		
		openFile(new File("c:\\test.txt"));
	}
}
